<?php

namespace app\common\model;
use think\Model;

class Address extends Model
{
    /**
     * 1.提交成功
     * 2.收货人
     * 3.收货地址
     * 4.电话
     * @param $post
     */
    public function add($post)
    {
//        dump($post['user']);die;
        if (!$post['user'])
        {
            return 2;
        }
        if (!$post['phone'])
        {
            return 4;
        }
        $AddressModel            = new Address();
        $AddressModel->names      = $post['user'];
        $AddressModel->user_id   = session('id');
        $AddressModel->tel       = $post['phone'];
        if ($post['qu'])
        {
            $qu = $post['qu'] . ',' . '';
        }else{
            $qu= '';
        }
        $AddressModel->address    = $post['sheng'] .','. $post['shi'] . ',' . $qu . $post['dizhi'];
        $AddressModel->save();
        return 1;
    }
}
